home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ For TASM / USRGUIDE.PAK / COUNTADD.ASM < prev    next >
Assembly Source File  |  1996-02-21  |  1KB  |  35 lines

  1. ; Turbo Assembler example. Copyright (c) 1993 By Borland International, Inc.
  2. ;
  3. ; COUNTADD.ASM  - Example of getting around name mangling
  4. ;
  5. ; Usage: bcc counter.cpp countadd.asm
  6. ;
  7. ; From the Turbo Assembler User's Guide, Ch. 18
  8.  
  9.      .MODEL small   ; Select small model (near code and data)
  10.      .CODE
  11.      PUBLIC _counter_increment
  12. _counter_increment  PROC
  13.      ARG count_offset:word      ; Address of the member variable
  14.      push bp                    ; Preserve caller's stack frame
  15.      mov  bp,sp                 ; Set our own stack frame
  16.      mov  bx,[count_offset]     ; Load pointer
  17.      inc  word ptr [bx]         ; Increment member variable
  18.      pop  bp                    ; Restore callers stack frame
  19.      ret
  20. _counter_increment  ENDP
  21.  
  22.      PUBLIC _counter_add
  23. _counter_add  PROC
  24.      ARG count_offset:word,what_to_add:word
  25.      push bp
  26.      mov  bp,sp
  27.      mov  bx,[count_offset]     ; Load pointer
  28.      mov  ax,[what_to_add]
  29.      add  [bx],ax
  30.      pop  bp
  31.      ret
  32. _counter_add  ENDP
  33.  
  34.      end
  35.